#ifndef THREE_DIMENSION_VIEW_H
#define THREE_DIMENSION_VIEW_H

#include <QWidget>
#include <QGLWidget>
#include <QMouseEvent>

#ifdef _WIN32
	#include <windows.h>
	#include <GL/gl.h>
	#include <GL/glu.h>
	#include "GLUT/glut.h"
#else
	#include <OpenGL/gl.h>
	#include <OpenGL/glu.h>
	#include <GLUT/glut.h>
#endif

#include <glm/glm.hpp>
#include "SketchModel.h"
#include "Trackball.h"
#include "Lighting.h"

class ThreeDimensionView : public QGLWidget
{
	Q_OBJECT

public:
	ThreeDimensionView(QWidget *parent);
	~ThreeDimensionView();

	void setSketchModel(SketchModel *model) { this->sketchModel = model; }

public slots:
	void loadSketchModel(SketchModel *model);

private:
	SketchModel *sketchModel;
	CTrackball  *trackball;
	CLighting   *lighting;

	bool first;
	float camDist;
	float xpos, ypos, zpos, xrot, yrot, angle;
	float fov;

	void initializeGL(); // Called before painting to set up the OpenGL environment
	void paintGL();      // 3D Painting
	void resizeGL(int w, int h); // Sets the OpenGL canvas to the size of the widget

	// Enables trackball rotation of camera around the origin
	void setCamera();

	void mouseMoveEvent(QMouseEvent *event);
	void mousePressEvent(QMouseEvent *event);
	void mouseReleaseEvent(QMouseEvent *event);
	void wheelEvent(QWheelEvent *event);
};

#endif // THREE_DIMENSION_VIEW_H
